package dk.au.cs.bdsi.sms.repositories;

import java.util.HashMap;
import java.util.LinkedList;

import dk.au.cs.bdsi.core.repositories.AbstractRepository;
import dk.au.cs.bdsi.core.representation.Identifier;
import dk.au.cs.bdsi.sms.domain.Sms;

public class SmsRepository extends AbstractRepository<Identifier, Sms> {
	private static SmsRepository Instance = null;
	
	private SmsRepository() {
		super(new HashMap<Identifier, Sms>(), new LinkedList<Sms>());
	}
	
	/**
	 * Retrieve the current message repository instance.
	 * 
	 * @return Current repository instance
	 */
	public static SmsRepository current() {
		if (Instance == null) {
			synchronized (SmsRepository.class) {
				if (Instance == null) {
					Instance = new SmsRepository();
				}
			}
		}
		return Instance;
	}

	@Override
	protected Identifier generateKey() {
		// Optimistic implementation, dependent on the uniqueness of Identifier
		return new Identifier();
	}
}
